package com.bw.z.mvp.model.entity;

import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

/**
 * {\"comment_address\":\"a\",
 * \"comment_time\":0,\"comment_fabulous\":10,
 * \"user_id\":1,\"comment_value\":\"a\",\"comment_id\":1,
 * \"news_id\":1}
 */
public class CommentEntity extends BaseEntity {


    public String values;

    public List<Values> getValues() {
        List<Values> list = new ArrayList<>();
        if (values == null)
            return null;
        try {
            JSONArray jsonArray = new JSONArray(values);
            for (int i = 0; i < jsonArray.length(); i++) {
                String str = jsonArray.getString(i);
                Values entity = new Gson().fromJson(str, Values.class);
                list.add(entity);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return list;
    }

    public static class Values {
        public String comment_address;
        public long comment_time;
        public int comment_fabulous;
        public int user_id;
        public String comment_value;
        public long comment_id;
        public long news_id;
    }

}
